MKTEMP

Section: MINTLIB LIBRARY FUNCTIONS (3)
Updated: 3 March 1993
Index Return to Main Contents
 

NAME

mktemp - make a unique file name  

SYNOPSIS

#include <unistd.h>

char *mktemp(char *template);
 

DESCRIPTION

mktemp creates a unique file name, typically in a temporary filesystem, by replacing template with a unique file name, and returns the address of template. The string in template should contain a file name with six trailing Xs; mktemp replaces the Xs with a number and the current process ID. The number will be chosen so that the resulting name does not duplicate an existing file.  

RETURN VALUES

mktemp returns a pointer to the changed template on success, and NULL on failure.  

SEE ALSO

getpid(3), open(3), tmpfile(3), tmpnam(3)  

NOTES

The related UN*X function mkstemp is currently not available in the mintlibs. mktemp actually changes the template string which you pass; this means that you cannot use the same template string more than once - you need a fresh template for every unique file you want to open. When mktemp is creating a new unique filename it checks for the prior existence of a file with that name. This means that if you are creating more than one unique filename, it is bad practice to use the same root template for multiple invocations of mktemp. The current process id is used only if there is enough room in the string and MiNT is active.  

BUGS

It is possible to run out of numbers.
 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
SEE ALSO
NOTES
BUGS

This document was created by man2html, using the manual pages.
Time: 11:14:57 GMT, June 22, 2025